/*
 * Copyright (C) 2023 xuexiangjys(xuexiangjys@163.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.xuexiang.templateproject.presenter;
import com.xuexiang.templateproject.bean.SubjectManagerEntity;
import com.xuexiang.templateproject.http.BaseObsrver;
import com.xuexiang.templateproject.http.BaseResponse;
//import com.xuexiang.templateproject.http.RxSchedulers;
import com.xuexiang.templateproject.http.RxSchedulers;
//import com.xuexiang.xhttp2.utils.RxSchedulers;
import com.xuexiang.templateproject.view.ImageBoxContract;
//import com.xuexiang.templateproject.view.SubjectContract;

import io.reactivex.Observable;
//import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;
import okhttp3.RequestBody;
//import l.z;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public final class ImageBoxPresenter extends BasePresenter<ImageBoxContract> {

    public final class SaveSchemaObsrver extends BaseObsrver<Object> {
        public SaveSchemaObsrver(ImageBoxContract jVar) {
            super(jVar, false);
        }

        @Override // com.jcds.common.rx.scheduler.BaseObsrver
        public void onSuccess(@Nullable Object obj) {
            ImageBoxContract c2 = ImageBoxPresenter.this.getMRootView();
            if (c2 != null) {
                c2.getSaveSchemaSuccess();
            }
        }
    }

    public final class SimpleSubmitObsrver extends BaseObsrver<Object> {
        public SimpleSubmitObsrver(ImageBoxContract jVar) {
            super(jVar, false);
        }

        @Override // com.jcds.common.rx.scheduler.BaseObsrver
        public void onSuccess(@Nullable Object obj) {
            ImageBoxContract c2 = ImageBoxPresenter.this.getMRootView();
            if (c2 != null) {
                c2.getSubmitSuccess();
            }
        }
    }

    public final class SubjectsObsrver extends BaseObsrver<SubjectManagerEntity> {
        public SubjectsObsrver(ImageBoxContract jVar) {
            super(jVar, false);
        }

        /* renamed from: a */
        public void onSuccess(@Nullable SubjectManagerEntity subjectManagerEntity) {
            ImageBoxContract c2 = ImageBoxPresenter.this.getMRootView();
            if (c2 != null) {
//                Intrinsics.checkNotNull(subjectManagerEntity);
                assert subjectManagerEntity != null;
                c2.getSubjectSuccess(subjectManagerEntity);
            }
        }
    }

    public void getSaveSchema(@NotNull String schema) {
        Intrinsics.checkNotNullParameter(schema, "schema");
        checkViewAttached();
        Observable<BaseResponse<Object>> saveScheam = getService().l(schema);
        RxSchedulers.Companion companion = RxSchedulers.Companion;
        ImageBoxContract rootView = getMRootView();
        Intrinsics.checkNotNull(rootView);
        Observable<BaseResponse<Object>> compose = saveScheam.compose(companion.request(rootView.getContext()));
        SaveSchemaObsrver disposable = compose.subscribeWith(new SaveSchemaObsrver(rootView));
//        Intrinsics.checkNotNullExpressionValue(disposable, "disposable");
        addSubscription(disposable);
    }

    public void getSimpleSubmit(@NotNull RequestBody body) {
        Intrinsics.checkNotNullParameter(body, "body");
        checkViewAttached();
        ImageBoxContract imageBoxContract = getMRootView();
        if (imageBoxContract != null) {
            imageBoxContract.showLoading();
        }
        Observable<BaseResponse<Object>> N = getService().N(body);
        RxSchedulers.Companion companion = RxSchedulers.Companion;
        Observable<BaseResponse<Object>> compose = N.compose(companion.request(imageBoxContract.getContext()));
        SimpleSubmitObsrver disposable = compose.subscribeWith(new SimpleSubmitObsrver(imageBoxContract));
        addSubscription(disposable);
    }

    public void getSubjects() {
        checkViewAttached();
        ImageBoxContract imageBoxContract = getMRootView();
        if (imageBoxContract != null) {
            imageBoxContract.showLoading();
        }
        Observable<BaseResponse<SubjectManagerEntity>> Z = getService().Z();
        RxSchedulers.Companion companion = RxSchedulers.Companion;
        assert imageBoxContract != null;
        Observable<BaseResponse<SubjectManagerEntity>> compose = Z.compose(companion.request(imageBoxContract.getContext()));
        SubjectsObsrver disposable = compose.subscribeWith(new SubjectsObsrver(imageBoxContract));
        addSubscription(disposable);
    }
}